package com.xbongbong.saas.model;

import com.xbongbong.paas.enums.DelEnum;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.pro.invoice.pojo.dto.InvoiceAmountDetailGetDTO;
import com.xbongbong.pro.invoice.pojo.vo.InvoiceAmountDetailVO;
import com.xbongbong.saas.domain.entity.ext.InvoiceEntityExt;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/25 10:18
 * @since v1.0
 */

public interface InvoiceModel extends IModel<InvoiceEntityExt> {

    /**
     * 获取单个实体
     *
     * @param key    id主键
     * @param corpid 公司id
     * @return com.xbongbong.saas.domain.entity.InvoiceEntityExt
     * @author feng.zheng
     * @date 2019/2/14 16:43
     */
    InvoiceEntityExt getByKey(Long key, String corpid);


    /**
     * 批量删除
     * @param idIn 数据id列表
     * @param corpid 公司id
     * @param del
     * @return
     * @throws XbbException
     */
    Integer deleteBatch(List<Long> idIn, String corpid, Integer del) throws XbbException;

    /**
     * 单个删除
     * @param id
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteByKey(Long id,String corpid) throws XbbException;

    /**
     * 单个删除，指定del
     * @param id
     * @param corpid
     * @param delEnum
     * @return java.lang.Integer
     * @throws XbbException
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    Integer deleteByKeyAppointDel(Long id, String corpid, DelEnum delEnum) throws XbbException;

    /**
     * 批量编辑
     * @author 吴峰
     * @date 2019/3/20 15:40
     * @param updateList
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid) throws XbbException;

    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    @Deprecated
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid,boolean needThrow) throws XbbException;

    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return 符合查询条件的记录
     */
    @Override
    List<InvoiceEntityExt> findEntitys(Map<String, Object> param);

    /**
     * 数据还原
     * @author xingxing.xiao
     */
    Integer restoreBatch(List<Long> dataIdList, String corpid, Integer del) throws XbbException;

    /**
     * 仅用于资金管理第一期 上线修复发票没有关联回款类型
     * @author yuqian
     * @return
     * @throws XbbException
     */
    List<InvoiceEntityExt> getAllInvoiceList(String corpid) throws XbbException;

    @Override
    List<InvoiceEntityExt> findEntitysWithoutSub(Map<String, Object> param);

    /**
     * 编辑时改变解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 获取红冲总金额
     *
     * @param originId 原始id
     * @param corpid   公司id
     * @return double
     * @throws XbbException 异常
     */
    Double getRedTotalMoney(Long originId, String corpid) throws XbbException;

    /**
     * 编辑时将获取数据格式化
     *
     * @param formDataUpdateGetDTO saas编辑数据
     * @param result               要返回的jsonobject
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/22 15:28
     */
    void formatData(SaasAnalysisDataDTO formDataUpdateGetDTO, JSONObject result) throws XbbException;

    /**
     * 获取销项发票金额明细
     * @param purchaseInvoiceAmountDetailGetDTO
     * @return
     */
    InvoiceAmountDetailVO getInvoiceAmountDetail(InvoiceAmountDetailGetDTO purchaseInvoiceAmountDetailGetDTO) throws XbbException;

    JSONArray approveGetSalesAmountDetail(String corpid, Integer businessType, JSONObject data, Long dataId, String saasNeedPoJo) throws XbbException;
}
